-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix for Source Argument Validation in SourceWorkflow for Default Source Type #4891
Merged
Madhusudhan-MSFT
merged 2 commits into
microsoft:master
from
Madhusudhan-MSFT:user/masudars/SourceCLI_DefaultSourceType_ValidationFix
Oct 21, 2024
Merged
Fix for Source Argument Validation in SourceWorkflow for Default Source Type #4891
Madhusudhan-MSFT
merged 2 commits into
microsoft:master
from
Madhusudhan-MSFT:user/masudars/SourceCLI_DefaultSourceType_ValidationFix
Oct 21, 2024
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…ce Type [Issues:] The current validation in the source flow correctly detects duplicate source names. However, when the source argument is validated along with the source type, it allows different source names with the same arguments for the empty source type. This happens because, during source type comparison, if the source type is not provided, it defaults to an empty string, which is compared against the default type (Microsoft.PreIndexed). This allows multiple different source names with the same argument to be considered valid sources. For an empty source type, the default source type is assigned during the source add operation, not beforehand. Consequently, after the source add operation is finished, the source will have some source arguments, but only the name will differ. [Fix:] For an empty source type, we should compare against the default source to prevent different source names with the same arguments for the default types. During validation, we obtain the default type to replace the empty source type and use it for comparison to validate argument duplication. - Extended source tests to validate the duplicate source argument scenario for the default source type. - Fixed additional failing source origin tests with appropriate fixes. [How Validated:] - Compiled the latest modifications and deployed the AppInstallerCLIPackage. - Executed CLI SourceTests to ensure all tests pass without issues.
This comment has been minimized.
This comment has been minimized.
yao-msft
approved these changes
Oct 21, 2024
Madhusudhan-MSFT
deleted the
user/masudars/SourceCLI_DefaultSourceType_ValidationFix
branch
October 21, 2024 21:42
ryfu-msft
pushed a commit
that referenced
this pull request
Oct 21, 2024
…ce Type (#4891) Fix for Source Argument Validation in SourceWorkflow for Default Source Type [Issues:] The current validation in the source flow correctly detects duplicate source names. However, when the source argument is validated along with the source type, it allows different source names with the same arguments for the empty source type. This happens because, during source type comparison, if the source type is not provided, it defaults to an empty string, which is compared against the default type (Microsoft.PreIndexed). This allows multiple different source names with the same argument to be considered valid sources. For an empty source type, the default source type is assigned during the source add operation, not beforehand. Consequently, after the source add operation is finished, the source will have some source arguments, but only the name will differ. [Fix:] For an empty source type, we should compare against the default source to prevent different source names with the same arguments for the default types. During validation, we obtain the default type to replace the empty source type and use it for comparison to validate argument duplication. - Extended source tests to validate the duplicate source argument scenario for the default source type. - Fixed additional failing source origin tests with appropriate fixes. [How Validated:] - Compiled the latest modifications and deployed the AppInstallerCLIPackage. - Executed CLI SourceTests to ensure all tests pass without issues. **[Manual validation:]** **Before fix:** ![image](https://github.com/user-attachments/assets/591b3ec2-ae6c-42ac-8258-169596657c4a) **After fix:** ![image](https://github.com/user-attachments/assets/2078b72a-d746-440c-a44e-2ec05c812e26) <!-- To check a checkbox place an "x" between the brackets. e.g: [x] --> - [x] I have signed the [Contributor License Agreement](https://cla.opensource.microsoft.com/microsoft/winget-pkgs). - [ ] This pull request is related to an issue. ----- ###### Microsoft Reviewers: [Open in CodeFlow](https://microsoft.github.io/open-pr/?codeflow=https://github.com/microsoft/winget-cli/pull/4891)
ryfu-msft
pushed a commit
that referenced
this pull request
Oct 21, 2024
…ce Type (#4891) Fix for Source Argument Validation in SourceWorkflow for Default Source Type [Issues:] The current validation in the source flow correctly detects duplicate source names. However, when the source argument is validated along with the source type, it allows different source names with the same arguments for the empty source type. This happens because, during source type comparison, if the source type is not provided, it defaults to an empty string, which is compared against the default type (Microsoft.PreIndexed). This allows multiple different source names with the same argument to be considered valid sources. For an empty source type, the default source type is assigned during the source add operation, not beforehand. Consequently, after the source add operation is finished, the source will have some source arguments, but only the name will differ. [Fix:] For an empty source type, we should compare against the default source to prevent different source names with the same arguments for the default types. During validation, we obtain the default type to replace the empty source type and use it for comparison to validate argument duplication. - Extended source tests to validate the duplicate source argument scenario for the default source type. - Fixed additional failing source origin tests with appropriate fixes. [How Validated:] - Compiled the latest modifications and deployed the AppInstallerCLIPackage. - Executed CLI SourceTests to ensure all tests pass without issues. **[Manual validation:]** **Before fix:** ![image](https://github.com/user-attachments/assets/591b3ec2-ae6c-42ac-8258-169596657c4a) **After fix:** ![image](https://github.com/user-attachments/assets/2078b72a-d746-440c-a44e-2ec05c812e26) <!-- To check a checkbox place an "x" between the brackets. e.g: [x] --> - [x] I have signed the [Contributor License Agreement](https://cla.opensource.microsoft.com/microsoft/winget-pkgs). - [ ] This pull request is related to an issue. ----- ###### Microsoft Reviewers: [Open in CodeFlow](https://microsoft.github.io/open-pr/?codeflow=https://github.com/microsoft/winget-cli/pull/4891)
Madhusudhan-MSFT
added a commit
to Madhusudhan-MSFT/winget-cli
that referenced
this pull request
Oct 21, 2024
- Integrate the fix from "Fix for Source Argument Validation in SourceWorkflow for Default Source Type" (microsoft#4891). This commit incorporates part of the included fix for consistency. - Updated the method of obtaining the default source type in the winrt::Microsoft::Management::Deployment::implementation namespace within PackageManager.cpp. Replaced the use of ::AppInstaller::Repository::ISourceFactory::GetForType("")->TypeName() with ::AppInstaller::Repository::Source::GetDefaultSourceType(). This change simplifies the process and ensures future-proofing against any changes in the SourceFactory's default type.
ryfu-msft
pushed a commit
that referenced
this pull request
Oct 22, 2024
…ce Type (#4891) Fix for Source Argument Validation in SourceWorkflow for Default Source Type [Issues:] The current validation in the source flow correctly detects duplicate source names. However, when the source argument is validated along with the source type, it allows different source names with the same arguments for the empty source type. This happens because, during source type comparison, if the source type is not provided, it defaults to an empty string, which is compared against the default type (Microsoft.PreIndexed). This allows multiple different source names with the same argument to be considered valid sources. For an empty source type, the default source type is assigned during the source add operation, not beforehand. Consequently, after the source add operation is finished, the source will have some source arguments, but only the name will differ. [Fix:] For an empty source type, we should compare against the default source to prevent different source names with the same arguments for the default types. During validation, we obtain the default type to replace the empty source type and use it for comparison to validate argument duplication. - Extended source tests to validate the duplicate source argument scenario for the default source type. - Fixed additional failing source origin tests with appropriate fixes. [How Validated:] - Compiled the latest modifications and deployed the AppInstallerCLIPackage. - Executed CLI SourceTests to ensure all tests pass without issues. **[Manual validation:]** **Before fix:** ![image](https://github.com/user-attachments/assets/591b3ec2-ae6c-42ac-8258-169596657c4a) **After fix:** ![image](https://github.com/user-attachments/assets/2078b72a-d746-440c-a44e-2ec05c812e26) <!-- To check a checkbox place an "x" between the brackets. e.g: [x] --> - [x] I have signed the [Contributor License Agreement](https://cla.opensource.microsoft.com/microsoft/winget-pkgs). - [ ] This pull request is related to an issue. ----- ###### Microsoft Reviewers: [Open in CodeFlow](https://microsoft.github.io/open-pr/?codeflow=https://github.com/microsoft/winget-cli/pull/4891)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix for Source Argument Validation in SourceWorkflow for Default Source Type
[Issues:] The current validation in the source flow correctly detects duplicate source names. However, when the source argument is validated along with the source type, it allows different source names with the same arguments for the empty source type. This happens because, during source type comparison, if the source type is not provided, it defaults to an empty string, which is compared against the default type (Microsoft.PreIndexed). This allows multiple different source names with the same argument to be considered valid sources. For an empty source type, the default source type is assigned during the source add operation, not beforehand. Consequently, after the source add operation is finished, the source will have some source arguments, but only the name will differ.
[Fix:]
For an empty source type, we should compare against the default source to prevent different source names with the same arguments for the default types. During validation, we obtain the default type to replace the empty source type and use it for comparison to validate argument duplication.
[How Validated:]
[Manual validation:]
Before fix:
After fix:
Microsoft Reviewers: Open in CodeFlow